package View;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.TextField;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import controller._Controller;

public class View implements _View{

	_Controller controller;
	TextField textField;
	JLabel textArea;
	JFrame frame1;
	Display display;
	 
	public View(_Controller controller){
		
		this.controller=controller;
		
		frame1 = new JFrame("2D Images ");
	    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    
	    display=new Display("New_Cover.jpg");
	    frame1.getContentPane().add("Center",display);
	    frame1.pack();
	    frame1.setSize(new Dimension(850, 820));
	    frame1.setVisible(true);
	    BorderLayout border=new BorderLayout();
	    
	    ActionListener listener=new Listener(this,controller);
	    
	    JPanel panel=new JPanel(new GridBagLayout());
	    panel.setSize(600,200);
	    
	    String input="<html><b>hello asda</b><html>";
	    
	    BorderLayout box=new BorderLayout();
	    
	    textArea=new JLabel();
	    textArea.setText("jhgjh");
	    //textArea.setSize(width, height)
	    panel.setLayout(box);
	    panel.add(textArea,BorderLayout.CENTER);
	    //JPanel panel=new JPanel();
	    //panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS));
	    
	    textField=new TextField();
	    textField.setSize(700, 100);
	    
	    panel.add(textField,BorderLayout.SOUTH);  
	    //c.gridwidth=GridBagConstraints.REMAINDER;
	    Button button=new Button("Go");
	    
	    button.addActionListener(listener);
	    panel.add(button,BorderLayout.EAST);
	    frame1.add(panel,border.SOUTH);
	    //frame1.add(panel,border.SOUTH);
	    textArea.setText(input);
	    
	}

	public void drawImage(String image) {
		
	}
	
	public String getText(){
		return textField.getText();
	}


	public void printOutput(String output) {
		textField.setText("");
		textArea.setText(output);
	}

	public void newChapter() {
		
		String fileName="furies";
		frame1.remove(display);
		display=new Display(fileName);
		frame1.getContentPane().add("Center",display);
	}

}
